/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.extensionpoints.lang;

import org.eclipse.core.runtime.IConfigurationElement;

/**
 * 
 */
public abstract class AbstractExtensionPoint {

	/**
	 * 
	 * 
	 * @param defaultValue 
	 * @param isRequired 
	 * @param configElt 
	 * @param name 
	 * 
	 * @return 
	 */
	protected static String getAttribute (
			IConfigurationElement configElt, String name, String defaultValue, boolean isRequired) {
		
		String value = configElt.getAttribute(name);
		
		if (value != null) {
			return value;
		} else if (defaultValue != null){
			return defaultValue;
		}
		
		if (isRequired) {
			throw new IllegalArgumentException("Missing "+ name + " attribute");
		}
		
		return null;
	}
}
